let {getBanners,getCategory} = require('../../api/indexApi');
Page({
  data: {
    banners: [],
    productTopicList: []
  },
  onLoad: function (options) {
    this.getImgList();
    this.getCategoryList();
  },
  //发送请求
  getImgList() {
    getBanners().then(res =>{
      if(res.data.code == 200){
        this.setData({banners:res.data.data})
      }
    })
  },
  //请求分页数据
  getCategoryList(){
    getCategory().then(res =>{
      console.log('分类数据获取结果:', res.data);
      if(res.data.code == 200) {
        //正确获取数据成功
        this.setData({productTopicList: res.data.data.productTopicList})
      }
    })
  },
  jumpWeb(ev) {
    let {url} = ev.target.dataset;
    wx.navigateTo({
      url: '/pages/web/web?url=' + url,
    })
  }
})
/* wx.request({
        url: 'http://123.56.83.71:2004/getBanner',
        success:res => {
          console.log('数据成功返回:', res.data);
        if(res.data.code == 200){
          this.setData({banners:res.data.data});
        }
        }
        let url = 'http://123.56.83.71:2004/getBanner';
      axios.get(url).then(res => {
          console.log('成功的数据', res);
        if(res.data.code == 200){
                  //成功获取到数据
        this.setData({banners:res.data.data});
          }
      })
      */